#include <iostream>
#include <vector>
using namespace std;

class CountIntervals {
        int n = 1000000000;
        int LIMIT = 800001;
        int cnt = 1;
        vector<int> left, right, sum;

        void up(int i, int l, int r)
        {
                sum[i] = sum[l] + sum[r];
        }

        void update(int jobl, int jobr, int v, int l, int r, int i)
        {
                if(sum[i] == r - l + 1){
                        return;
                }
                if(jobl <= l && r <= jobr){
                        sum[i] = r - l + 1;
                        return;
                }
                int mid = (l + r) >> 1;
                if(jobl <= mid){
                        if(left[i] == 0){
                                left[i] = ++cnt;
                        }
                        update(jobl, jobr, v, l, mid, left[i]);
                }
                if(mid < jobr){
                        if(right[i] == 0){
                                right[i] = ++cnt;
                        }
                        update(jobl, jobr, v, mid + 1, r, right[i]);
                }
                up(i, left[i], right[i]);
        }
    public:
	CountIntervals()
        :sum(LIMIT, 0), left(LIMIT, 0), right(LIMIT, 0)
	{
	}

	void add(int left, int right)
	{
                update(left, right, 1, 1, n, 1);
	}

	int count()
	{
                return sum[1];
	}
};

int main()
{

	return 0;
}